package org.opens.lambda;

import lombok.Data;

import java.io.Serializable;
import java.util.Comparator;

@Data
public class Banana implements Serializable, Comparator<Banana> {

    private String name;

    private Integer size;

    @Override
    public int compare(Banana banana, Banana anotherBanana) {
        int comparResult = Integer.compare(banana.getSize(), anotherBanana.getSize());
        if(comparResult == 0) {
            comparResult = banana.getName().compareTo(anotherBanana.getName());
        }
        return comparResult;
    }
}
